Ext.define('SKJF.view.MASTER.v_mstcustomer_form', {
	extend	: 'Ext.form.Panel',
	
	alias	: 'widget.v_mstcustomer_form',
	
	region:'east',
	id: 'east-region-container',
	
	title		: 'Create/Update mstcustomer',
    bodyPadding	: 5,
    autoScroll	: true,
    
    initComponent: function(){
    	/*
		 * Deklarasi variable setiap field
		 */
		 
		var KODE_CUSTOMER_field = Ext.create('Ext.form.field.Text', {
			itemId: 'KODE_CUSTOMER_field',
			name: 'KODE_CUSTOMER', /* column name of table */
			fieldLabel: 'KODE_CUSTOMER',
			readOnly:true,
			allowBlank: true
		});
		var NAMA_CUSTOMER_field = Ext.create('Ext.form.field.Text', {
			itemId: 'NAMA_CUSTOMER_field',
			name: 'NAMA_CUSTOMER', /* column name of table */
			fieldLabel: 'NAMA_CUSTOMER',
			maxLength: 100,
			style : {textTransform: "uppercase"},
			enableKeyEvents: true,
			listeners: {
				'change': function(field, newValue, oldValue){
					//field.setValue(newValue.toUpperCase());
					Ext.util.Format.capitalize = (function(){
						var re = /(^|[^\w])([a-z])/g,
							fn = function(m, a, b) {
								return a + b.toUpperCase();
							};
						return function(v){
							return v.toLowerCase().replace(re, fn);
						}
					})();
					field.setValue(Ext.util.Format.capitalize(newValue));
				}
			}
		});
		var CONTACT_PERSON_field = Ext.create('Ext.form.field.Text', {
			name: 'CONTACT_PERSON', /* column name of table */
			fieldLabel: 'CONTACT_PERSON',
			maxLength: 200,
			style : {textTransform: "uppercase"},
			enableKeyEvents: true,
			listeners: {
				'change': function(field, newValue, oldValue){
					//field.setValue(newValue.toUpperCase());
					Ext.util.Format.capitalize = (function(){
						var re = /(^|[^\w])([a-z])/g,
							fn = function(m, a, b) {
								return a + b.toUpperCase();
							};
						return function(v){
							return v.toLowerCase().replace(re, fn);
						}
					})();
					field.setValue(Ext.util.Format.capitalize(newValue));
				}
			}
		});
		var LIMIT_HUTANG_field = Ext.create('Ext.form.field.Number', {
			name: 'LIMIT_HUTANG', /* column name of table */
			fieldLabel: 'LIMIT_HUTANG'
		});
		var ALAMAT_1_field = Ext.create('Ext.form.field.Text', {
			name: 'ALAMAT_1', /* column name of table */
			fieldLabel: 'ALAMAT_1',
			maxLength: 200,
			style : {textTransform: "uppercase"},
			enableKeyEvents: true,
			listeners: {
				'change': function(field, newValue, oldValue){
					//field.setValue(newValue.toUpperCase());
					Ext.util.Format.capitalize = (function(){
						var re = /(^|[^\w])([a-z])/g,
							fn = function(m, a, b) {
								return a + b.toUpperCase();
							};
						return function(v){
							return v.toLowerCase().replace(re, fn);
						}
					})();
					field.setValue(Ext.util.Format.capitalize(newValue));
				}
			}
		});
		var ALAMAT_2_field = Ext.create('Ext.form.field.Text', {
			name: 'ALAMAT_2', /* column name of table */
			fieldLabel: 'ALAMAT_2',
			maxLength: 200,
			style : {textTransform: "uppercase"},
			enableKeyEvents: true,
			listeners: {
				'change': function(field, newValue, oldValue){
					//field.setValue(newValue.toUpperCase());
					Ext.util.Format.capitalize = (function(){
						var re = /(^|[^\w])([a-z])/g,
							fn = function(m, a, b) {
								return a + b.toUpperCase();
							};
						return function(v){
							return v.toLowerCase().replace(re, fn);
						}
					})();
					field.setValue(Ext.util.Format.capitalize(newValue));
				}
			}
		});
		var KOTA_field = Ext.create('Ext.form.field.Text', {
			name: 'KOTA', /* column name of table */
			fieldLabel: 'KOTA',
			maxLength: 30,
			style : {textTransform: "uppercase"},
			enableKeyEvents: true,
			listeners: {
				'change': function(field, newValue, oldValue){
					//field.setValue(newValue.toUpperCase());
					Ext.util.Format.capitalize = (function(){
						var re = /(^|[^\w])([a-z])/g,
							fn = function(m, a, b) {
								return a + b.toUpperCase();
							};
						return function(v){
							return v.toLowerCase().replace(re, fn);
						}
					})();
					field.setValue(Ext.util.Format.capitalize(newValue));
				}
			}
		});
		var TELPON_field = Ext.create('Ext.form.field.Text', {
			name: 'TELPON', /* column name of table */
			fieldLabel: 'TELPON',
			maxLength: 100 /* length of column name */
		});
		var FAX_field = Ext.create('Ext.form.field.Text', {
			name: 'FAX', /* column name of table */
			fieldLabel: 'FAX',
			maxLength: 100 /* length of column name */
		});
		var EMAIL_field = Ext.create('Ext.form.field.Text', {
			name: 'EMAIL', /* column name of table */
			fieldLabel: 'EMAIL',
			maxLength: 50 /* length of column name */
		});
		var NPWP_field = Ext.create('Ext.form.field.Text', {
			name: 'NPWP', /* column name of table */
			fieldLabel: 'NPWP',
			maxLength: 25 /* length of column name */
		});		
        Ext.apply(this, {
            fieldDefaults: {
                labelAlign: 'right',
                labelWidth: 120,
                msgTarget: 'qtip',
				anchor: '100%'
            },
			defaultType: 'textfield',
            items: [KODE_CUSTOMER_field,NAMA_CUSTOMER_field,CONTACT_PERSON_field,LIMIT_HUTANG_field,ALAMAT_1_field,ALAMAT_2_field,KOTA_field,TELPON_field,FAX_field,EMAIL_field,NPWP_field],
			
	        buttons: [{
                iconCls: 'icon-save',
                itemId: 'save',
                text: 'Save',
                disabled: true,
                action: 'save'
            }, {
                iconCls: 'icon-add',
				itemId: 'create',
                text: 'Create',
                action: 'create'
            }, {
                iconCls: 'icon-reset',
                text: 'Cancel',
                action: 'cancel'
            }]
        });
        
        this.callParent();
    }
});